/************** init.html **************/
function query_invReceipts(page) {
	sys_loading();
	var parm = $('#queryinvReceiptsForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('invReceipts-query');
	sys_record_parm('invReceipts',parm);
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#ResultList').html(result);
		}
	});
}
function shield_invReceipts(code) {
	$.Zebra_Dialog('确定要屏蔽吗？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
       {caption:'屏蔽',callback:function() {
    	   var url = create_url('invReceipts-shield');
    	   aidExecute_invReceipts(code, url);
		}},
       {caption:'取消',callback:function(){}
       }]
	});
}

function unshield_invReceipts(code) {
	$.Zebra_Dialog('确定要解除屏蔽吗？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
       {caption:'解除',callback:function() {
    	   var url = create_url('invReceipts-unshield');
    	   aidExecute_invReceipts(code, url);
		}},
       {caption:'取消',callback:function(){}
       }]
	});
}

function aidExecute_invReceipts(code, url) {
	var parm = {'code':code};
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if ('success' == result) {
				query_invReceipts();
			} else {
				sys_msg('操作失败，请刷新页面再次尝试，如果问题依然存在，请联系管理员!');
			}
		}
	});
}

function save_invReceipts() {
	var parm = $('#editinvReceiptsForm').serialize();
	var url = create_url('invReceipts-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if (result == 'success') {
				sys_msg('操作成功!');
				sys_load_handle('invReceipts');
			} else if(result == 'exists') {
				sys_msg('名称重复!');
			} else {
				sys_msg('操作失败！')
			}
		}
	});
}

//查询来往商
function aidQueryBn_invReceipts(page) {
	sys_loading();
	var parm = $('#aidQueryBnForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('invReceipts-aidList');
	$.ajax({type:'POST', url:url, data:parm,success: function(result) {
			sys_loading_close();
			$('#aidBnResultList').html(result);
			}
		 });
	}

function selectBn_invReceipts() {
	var url = create_url('invReceipts-aidInit');
	var parm = {'id':'bc', 'name':'bn'};
	$.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'900px', height:'700px', open:true, 
			onClosed:function(){
			}
		});
	}

//选择来往商
function chooseBn_invReceipts(code, name) {
	$('#bc').val(code);
	$('#bn').val(name);
	$.fn.colorbox.close();
}

//查询结算方式
function aidQuerySn_invReceipts(page) {
	sys_loading();
	var parm = $('#aidQuerySnForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('invReceipts-aidList1');
	$.ajax({type:'POST', url:url, data:parm,success: function(result) {
			sys_loading_close();
			$('#aidSnResultList').html(result);
			}
		 });
	}

function selectSn_invReceipts() {
	var url = create_url('invReceipts-aidInit1');
	var parm = {'id':'sc', 'name':'sn'};
	$.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'900px', height:'700px', open:true, 
			onClosed:function(){
			}
		});
	}

//选择
function chooseSn_invReceipts(code, name) {
	$('#sc').val(code);
	$('#sn').val(name);
	$.fn.colorbox.close();
}

//查询账号
function aidQueryAn_invReceipts(page) {
	sys_loading();
	var parm = $('#aidQueryAnForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('invReceipts-aidList2');
	$.ajax({type:'POST', url:url, data:parm,success: function(result) {
			sys_loading_close();
			$('#aidAnResultList').html(result);
			}
		 });
	}

function selectAn_invReceipts() {
	var url = create_url('invReceipts-aidInit2');
	var parm = {'id':'ac', 'name':'an'};
	$.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'900px', height:'700px', open:true, 
			onClosed:function(){
			}
		});
	}

//选择账号
function chooseAn_invReceipts(code, card) {
	$('#ac').val(code);
	$('#an').val(card);
	$.fn.colorbox.close();
}
